﻿using AnQinFrameWorkAPI.Entity.Blog.DTO.BlogDevelopHistory;
using AnQinFrameWorkAPI.Entity.Blog.View.BlogDevelopHistory;
using AnQinFrameWorkAPI.Service.Blog;
using FrameWork.Entity;
using Microsoft.AspNetCore.Mvc;

namespace AnQinFrameWorkAPI.Controllers.Blog;

/// <summary>
///     博客发展历程API
/// </summary>
[Route("api/[controller]")]
[ApiController]
[ApiExplorerSettings(GroupName = "Blog")]
public class BlogDevelopHistoryController : ControllerBase
{
    // 业务服务接口
    private readonly BlogDevelopHistoryService _blogDevelopHistoryService;

    // 构造注入
    public BlogDevelopHistoryController(BlogDevelopHistoryService blogDevelopHistoryService)
    {
        _blogDevelopHistoryService = blogDevelopHistoryService;
    }

    /// <summary>
    ///     获取发展历程列表（分页）
    /// </summary>
    /// <param name="searchDTO">查询条件</param>
    [ProducesResponseType(typeof(BlogDevelopHistoryView), 200)]
    [HttpGet]
    public async Task<IActionResult> GetBlogDevelopHistoryList([FromQuery] BlogDevelopHistorySearchDTO searchDTO)
    {
        var response = await _blogDevelopHistoryService.GetBlogDevelopHistoryList(searchDTO);
        return StatusCode(response.Status, response);
    }

    /// <summary>
    ///     新增发展历程
    /// </summary>
    /// <param name="addDTO">历程数据</param>
    [HttpPost]
    public async Task<IActionResult> AddBlogDevelopHistory([FromBody] BlogDevelopHistoryAddDTO addDTO)
    {
        var response = await _blogDevelopHistoryService.AddBlogDevelopHistory(addDTO);
        return StatusCode(response.Status, response);
    }

    /// <summary>
    ///     更新发展历程
    /// </summary>
    /// <param name="updateDTO">历程数据</param>
    [HttpPut]
    public async Task<IActionResult> PutBlogDevelopHistory([FromBody] BlogDevelopHistoryUpdateDTO updateDTO)
    {
        var response = await _blogDevelopHistoryService.PutBlogDevelopHistory(updateDTO);
        return StatusCode(response.Status, response);
    }

    /// <summary>
    ///     删除发展历程
    /// </summary>
    /// <param name="deleteDTO">删除参数</param>
    [HttpDelete]
    public async Task<IActionResult> DeleteBlogDevelopHistory([FromBody] SingleIdDTO deleteDTO)
    {
        var response = await _blogDevelopHistoryService.DeleteBlogDevelopHistory(deleteDTO);
        return StatusCode(response.Status, response);
    }
}